package com.example.java_gobang.config;

import com.example.java_gobang.model.Result;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.servlet.resource.NoResourceFoundException;
@ControllerAdvice
@ResponseBody
@Slf4j
public class ExceptionAdvice{
    @ExceptionHandler
    public Result handle(Exception e){
        log.error("出现错误 e:",e);
        return Result.fail("内部错误，联系管理员");
    }
    @ExceptionHandler
    public Result handle(NoResourceFoundException e){
        log.error("文件不存在 e:",e.getMessage());
        return Result.fail("内部错误，联系管理员");
    }
}
